//  ========== 
//  = 我的_点点专享_回款计划 业务JS = 
//  ==========
var bidId;
var Main = function(){
	mui.init({
		swipeBack:true 		//启用右滑关闭功能
	});
	this.init();
	this.loadData();
};
Main.prototype = {
	init : function(){
		mui('.mui-scroll-wrapper').scroll({
					indicators: true //是否显示滚动条
		});
		var _this = this;
		_this.eventInit()
		
	},
	eventInit : function(){//绑定事件
		var _this = this;
        
	},
   _getFundTypeName:function(fundType){
	   	var fundTypeName = '';
	   	if(fundType == 'principalRepayment'){
	   		fundTypeName='本金';
	   	}else if(fundType == 'loanInterest'){
	   		fundTypeName='利息 ';
	   	}else if(fundType == 'liquidatedDamages'){
	   		fundTypeName='提前赎回违约金';
	   	}else if(fundType == 'riskRate'){
	   		fundTypeName='风险保证金';
	   	}else if(fundType == 'couponInterest'){
	   		fundTypeName='优惠券利息奖励';
	   	}else if(fundType == 'principalCoupons'){
	   		fundTypeName='优惠券返现奖励';
	   	}else if(fundType == 'subjoinInterest'){
	   		fundTypeName='加息券加息奖励';
	   	}else if(fundType == 'commoninterest'){
	   		fundTypeName='普通加息';
	   	}else if(fundType == 'raiseinterest'){
	   		fundTypeName='募集期奖励';
	   	}
	   	return fundTypeName;
   },
	//内容列表
	loadData : function(_callback){
		var _this = this;
		orderId = Util.requestURL('orderId');
		var param = {
				isMobile:1,
				memberId:Util.getLoginUser().memberId,
				orderId:orderId
				};
		var url = server_url+'/creditFlow/financingAgency/assigninterestlistPlManageMoneyPlanBuyinfo.do';
		$.getJSON(url,param  ,function(retData){
			var _html = '';
			if(retData.success){
	           for(var i=0;i<retData.result.length;i++){
	            	var item = retData.result[i];
					_html += '\n <li class="mui-table-view-cell ">';
		            _html += '\n <h5>期数:第'+item.periods+'期</h5>';
		            _html += '\n <h5>类型:'+_this._getFundTypeName(item.fundType)+'</h5>';
			           var planMoney = "";
			           if(item.incomeMoney==0){
			           	if(list.payMoney==0){
			           		planMoney = "0"
			           	}else{
			           		planMoney = "-"+item.payMoney;
			           	}
			           }else{
			           	planMoney = item.incomeMoney;
			           }
		            _html += '\n <h5>计划回款金额:¥'+planMoney+'</h5>';
		            var factMoney = "";
		            if(item.incomeMoney==0){
		            	factMoney = "-";
		            }
	            	if(item.afterMoney==0){
	            		factMoney ="0";
	            	}else{
	            		factMoney += item.afterMoney;
	            	}
		            _html += '\n <h5>实际回款金额:¥'+factMoney+'</h5>';
		            _html += '\n <h5>计划到账日:'+Util.time.formatDate(new Date(item.intentDate),'yyyy-MM-dd')+'</h5>';
		            _html += '\n <h5>实际到账日:'+Util.safeString(item.factDate,'-- --')+'</h5>';
				    _html += '\n </li>';
				}	
            }
             $('.m-item-list').append(_html);
             
             if($.isFunction(_callback)){
             	_callback();
             }
		});
	}
	
}
